package com.movie.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.movie.comm.utils.PageData;
import com.movie.dao.AdminDao;
import com.movie.dao.impl.AdminDaoImpl;

/**
 * 
* @ClassName: AdminLoginAction 
* @Description: 管理员登陆的业务逻辑 
* @author 左岩
* @date 2018年12月6日 下午7:49:50 
*
 */
@WebServlet(urlPatterns="/adminLoginAction")
public class AdminLoginAction extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		PageData pageData = new PageData(request);
		AdminDao adminDao = new AdminDaoImpl();
		boolean isSuccess = adminDao.adminLogin(pageData);
		if (isSuccess) {
			request.getRequestDispatcher("WEB-INF/page/admin/index.jsp").forward(request, response);
		} else {
			request.setAttribute("errorMessage", "账号或密码错误,请重新输入！！");
			request.getRequestDispatcher("WEB-INF/page/admin/login.jsp").forward(request, response);
		}
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
